<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //String类型
        let name = "单欣烁";
        console.log(name);
        console.log(typeof name);
        //number类型
        let cost = 20;
        console.log(cost)
        console.log(typeof cost)
        //常量
        const PI = 3.1415;
        name = "David";
        console.log(name);
        // PI = 6.2;
        console.log(PI);
        //布尔类型
        let tv = true
        console.log("tv", tv)
        console.log(typeof tv)
        //对象类型
        let girl = {
            name: "单欣烁",
            age: 19,
            flag: true
        }
        console.log("girl", girl)
        console.log(typeof girl)
        //新增的map类型(注意是大写的Map)键值对
        let girls = new Map([
            ["name", "luna"],
            ["age", 18]
        ])
        console.log("girls", girls)
        console.log(typeof girls)
        //set存储无序且唯一的值（包含元素不重复）
        let numbers = new Set([1, 2, 3])
        // let numbers = new Set([1, 2, 3, 2, 1])
        console.log(numbers)
        console.log(typeof numbers)
        //数组：可重复
        let arr = ["a", "b", "c", "a"]
        console.log(arr)
        console.log(typeof arr)
        //函数：function
        function add(x, y) {
            console.log(x + y)
        }
        add(10, 20)
        //类：class
        class Person {
            constructor(name, age) {
                this.name = name;
                this.age = age;
            }
            info() {
                console.log(this.name, this.age)
            }
        }
        //创建一个对象，传进去参数
        const p1 = new Person("瑶瑶", 22)
        p1.info()
    </script>
</body>

</html>